<!--
 * @Author: your name
 * @Date: 2020-10-22 10:45:11
 * @LastEditTime: 2021-01-13 15:14:52
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \sende_nuxt\pages\login\index.vue
-->
<template>
  <div class="w1200auto login ptb50">
    <div class="login_box">
      <h3 class="login_title size20 b text_c ptb20 mb20">{{$t('login.Login To Eyecedar')}}</h3>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="login-ruleForm">
        <el-form-item prop="username">
          <el-input v-model="ruleForm.username"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input type="password" v-model="ruleForm.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')">{{$t('login.LOGIN')}}</el-button>
        </el-form-item>
      </el-form>
      <div class="login_remember mb20">
          <el-checkbox v-model="isRemember">{{$t('login.Remember Me')}}</el-checkbox>
          <nuxt-link class="login_forget size12 underline" to="/forget">{{$t('login.Forgot Your Password?')}}</nuxt-link>
      </div>
      <div class="login_createAccount ptb30">
        <h3 class="size20 b text_c text_l mb20">{{$t('login.NEW CUSTOMERS')}}</h3>
        <nuxt-link class="login_register size15 underline" to="/register">{{$t('login.Create an Account')}}</nuxt-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  asyncData: ({ req }) => {
    
    return {
      ruleForm: {
        username: '',
        password: '',
      },
      rules: {
        username: [
          { required: true, message: 'This is a required field.', trigger: 'blur' },
          { min: 8, max: 16, message: 'length 3 or 5 string', trigger: 'blur' }
        ],
        password: [
          { required: true, message: 'This is a required field.', trigger: 'blur' },
          { min: 8, max: 16, message: 'length 3 or 5 string', trigger: 'blur' }
        ]
      },
      isRemember: false
    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
  },
  head() {
    return {
      title: this.$t("login.login"),
      meta: [
        { hid: "keywords", name: "keywords", content: this.$t("login.login") },
        {
          hid: "description",
          name: "description",
          content: this.$t("login.login"),
        },
      ],
    };
  },
};
</script>

<style lang="scss" scoped>
@import "~/assets/scss/index.scss";
.login {
    @include flex-center(center);
    &_box {
      width: 370px;
    }
    &_remember {
      @include flex-center(space-between);
      padding: 5px 0;
    }
    &_createAccount {
      border-top: 1px solid $ddd;
    }
    &_forget,
    &_register {
      color: $theme;
    }
}

.login .el-button {
  width: 100%;
  border-radius: unset;
  padding-top: 15px;
  padding-bottom: 15px;
  font-weight: bold;
  font-size: 14px;
}
.login .el-form-item:last-child {
  margin-bottom: 10px;
}
</style>